/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import React from "react";

export default function(sourceType) {
  const orderSetConfig = {
    derivative: {
      fieldName: {},
      actionTypes: {
        getSetterList: "setter/getWxSetterList",
        editOrderSource: "setter/wsEditOrderSource",
        addOrderSource: "setter/wsAddOrderSource",
      },
      stateNameConfig: {
        setterList: "wxSetterList",
      },
      columns: [
        {
          title: "店铺名称",
          dataIndex: "shop_name",
          key: "shop_name",
          align: "center",
        },
        {
          title: "绑定手机号",
          dataIndex: "phone",
          key: "phone",
          align: "center",
        },
        {
          title: "快递品牌",
          dataIndex: "brand_name",
          key: "brand_type",
          align: "center",
          render: (text, record, index) => {
            const { waybill_source } = record;
            return waybill_source.map((item, index) => {
              return <p key={item.id}>{item.brand_name}</p>;
            });
          },
        },
        {
          title: "价格",
          dataIndex: "price",
          key: "price",
          align: "center",
          render: (text, record, index) => {
            const { waybill_source } = record;

            return waybill_source.map(item => {
              return <p key={item.id}>{item.price}</p>;
            });
          },
        },
        {
          title: "可用单号数量",
          dataIndex: "waybill_quantity",
          key: "waybill_quantity",
          align: "center",
          render: (text, record, index) => {
            const { waybill_source } = record;

            return waybill_source.map(item => {
              return (
                <p key={item.id}>{item.waybill_quantity < 0 ? "无限" : item.waybill_quantity}</p>
              );
            });
          },
        },
        {
          title: "状态",
          dataIndex: "status",
          key: "status",
          align: "center",
          render: (text, record, index) => {
            const { waybill_source } = record;

            return waybill_source.map(item => {
              return (
                <p key={item.id}>
                  {item.status == "0" ? "关闭" : item.status == "1" ? "开启" : item.status}
                </p>
              );
            });
          },
        },
        {
          title: "单号源操作",
          align: "center",
          render: (value, record) => {
            const { waybill_source, user_id } = record;
            return (
              <a onClick={this.onTriggerModal.bind(this, true, waybill_source, user_id)}>设置</a>
            );
          },
        },
      ],
      searchBarConfig: {
        site_id: {
          show: false,
        },
        keyword: {
          name: "keyword",
          placeholder: "可根据店铺手机号搜索",
          width: 350,
        },
        jumpToAddWs: {
          show: true,
        },
      },
    },
    yz: {
      fieldName: {},
      actionTypes: {
        getSetterList: "setter/getYzSetterList",
        editOrderSource: "setter/yzEditOrderSource",
        // addOrderSource: "setter/wsAddOrderSource",
      },
      stateNameConfig: {
        setterList: "yzSetterList",
      },
      columns: [
        {
          title: "驿站名称",
          dataIndex: "inn_name",
          key: "inn_name",
          align: "center",
        },
        {
          title: "联系电话",
          dataIndex: "phone",
          key: "phone",
          align: "center",
          render: (text, record) => `${record.concat_name}-${text}`,
        },
        {
          title: "快递品牌",
          dataIndex: "brand_name",
          key: "brand_type",
          align: "center",
          render: (text, record, index) => {
            const { waybill_source } = record;
            return waybill_source.map((item, index) => {
              return <p key={item.id}>{item.brand_name}</p>;
            });
          },
        },
        {
          title: "价格",
          dataIndex: "price",
          key: "price",
          align: "center",
          render: (text, record, index) => {
            const { waybill_source } = record;

            return waybill_source.map(item => {
              return <p key={item.id}>{item.price}</p>;
            });
          },
        },
        {
          title: "可用单号数量",
          dataIndex: "waybill_quantity",
          key: "waybill_quantity",
          align: "center",
          render: (text, record, index) => {
            const { waybill_source } = record;

            return waybill_source.map(item => {
              return (
                <p key={item.id}>{item.waybill_quantity < 0 ? "无限" : item.waybill_quantity}</p>
              );
            });
          },
        },
        {
          title: "状态",
          dataIndex: "status",
          key: "status",
          align: "center",
          render: (text, record, index) => {
            const { waybill_source } = record;

            return waybill_source.map(item => {
              return (
                <p key={item.id}>
                  {item.status == "0" ? "关闭" : item.status == "1" ? "开启" : item.status}
                </p>
              );
            });
          },
        },
        {
          title: "单号源操作",
          align: "center",
          render: (value, record) => {
            const { waybill_source, cm_id } = record;
            return (
              <a onClick={this.onTriggerModal.bind(this, true, waybill_source, cm_id)}>设置</a>
            );
          },
        },
      ],
      searchBarConfig: {
        site_id: {
          show: false,
        },
        keyword: {
          name: "keyword",
          placeholder: "可根据联系电话、驿站名称搜索",
          width: 350,
        },
        jumpToAddWs: {
          show: false,
        },
      },
    },
    operator: {
      fieldName: {},
      actionTypes: {
        getSetterList: "setter/getSetterList",
        editOrderSource: "setter/editOrderSource",
        addOrderSource: "setter/addOrderSource",
      },
      stateNameConfig: {
        setterList: "setterList",
      },
      columns: [
        {
          title: "站点",
          dataIndex: "site_name",
          key: "site_name",
          align: "center",
        },
        {
          title: "业务员",
          dataIndex: "courier_info",
          key: "courier_info",
          align: "center",
        },
        {
          title: "快递品牌",
          dataIndex: "brand_name",
          key: "brand_type",
          align: "center",
          render: (text, record, index) => {
            const { waybill_source } = record;
            return waybill_source.map((item, index) => {
              return <p key={item.id}>{item.brand_name}</p>;
            });
          },
        },
        {
          title: "价格",
          dataIndex: "price",
          key: "price",
          align: "center",
          render: (text, record, index) => {
            const { waybill_source } = record;

            return waybill_source.map(item => {
              return <p key={item.id}>{item.price}</p>;
            });
          },
        },
        {
          title: "可用单号数量",
          dataIndex: "waybill_quantity",
          key: "waybill_quantity",
          align: "center",
          render: (text, record, index) => {
            const { waybill_source } = record;

            return waybill_source.map(item => {
              return (
                <p key={item.id}>{item.waybill_quantity < 0 ? "无限" : item.waybill_quantity}</p>
              );
            });
          },
        },
        {
          title: "状态",
          dataIndex: "status",
          key: "status",
          align: "center",
          render: (text, record, index) => {
            const { waybill_source } = record;

            return waybill_source.map(item => {
              return (
                <p key={item.id}>
                  {item.status == "0" ? "关闭" : item.status == "1" ? "开启" : item.status}
                </p>
              );
            });
          },
        },
        {
          title: "单号源操作",
          align: "center",
          render: (value, record) => {
            const { waybill_source, user_id } = record;
            return (
              <a onClick={this.onTriggerModal.bind(this, true, waybill_source, user_id)}>设置</a>
            );
          },
        },
      ],
      searchBarConfig: {
        site_id: {
          show: true,
        },
        keyword: {
          name: "keyword",
          placeholder: "可根据业务员手机号或者姓名搜索",
          width: 250,
        },
        jumpToAddWs: {
          show: false,
        },
      },
    },
  };
  const { actionTypes, stateNameConfig, columns, searchBarConfig, fieldName } = orderSetConfig[
    sourceType
  ];
  return { actionTypes, stateNameConfig, columns, searchBarConfig, fieldName };
}
